package com.csx.micrometer.discovery.controller;

import com.csx.micrometer.discovery.model.HttpServiceDiscoveryVO;
import com.csx.micrometer.discovery.service.MicrometerServiceDiscoveryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 通过服务发现的方式让Prometheus批量发现节点
 * @author cuisongxu
 * @date 2022/12/5 16:19
 */
@RequestMapping("/micrometer-service-discovery")
@RestController
public class MicrometerServiceDiscoveryController {

    @Autowired
    private MicrometerServiceDiscoveryService micrometerServiceDiscoveryService;

    /**
     * Prometheus从该端点获取所有探测点，配置如下:
     */
    @GetMapping
    public List<HttpServiceDiscoveryVO> queryServiceDiscoveryList() {
        return micrometerServiceDiscoveryService.getServiceDiscoveryList();
    }
}
